package com.deere.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;


@Entity
public class ProductionOrderItem extends GenericModel {
	private Integer itemId;
	private ProductionOrder proOrder;
	private GenericPart part;
	private Integer plannedQty;
	private Integer finishedQty=0;
	private Boolean self;
	
	private Boolean completed=false;
	
	private Set<WorkOrder> workOrdrers;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getItemId() {
		return itemId;
	}
	public void setItemId(Integer itemId) {
		this.itemId = itemId;
	}
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "productionOrder")
	public ProductionOrder getProOrder() {
		return proOrder;
	}
	public void setProOrder(ProductionOrder proOrder) {
		this.proOrder = proOrder;
	}
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "partCode")
	public GenericPart getPart() {
		return part;
	}
	public void setPart(GenericPart part) {
		this.part = part;
	}
	public Integer getPlannedQty() {
		return plannedQty;
	}
	public void setPlannedQty(Integer plannedQty) {
		this.plannedQty = plannedQty;
	}
	@Column(columnDefinition="int default 0")
	public Integer getFinishedQty() {
		return finishedQty;
	}
	public void setFinishedQty(Integer finishedQty) {
		this.finishedQty = finishedQty;
	}
	
	public Boolean getSelf() {
		return self;
	}
	public void setSelf(Boolean self) {
		this.self = self;
	}
	/**
	 * 是否完成标记。
	 * 默认值为0/b'0'，即没有完成。
	 * 为1/b'1'时，即表示完成。
	 * @return
	 */
	public Boolean getCompleted() {
		return completed;
	}
	public void setCompleted(Boolean completed) {
		this.completed = completed;
	}
	@OneToMany(fetch=FetchType.EAGER)
	@JoinColumn(name="itemId")
	public Set<WorkOrder> getWorkOrdrers() {
		return workOrdrers;
	}
	public void setWorkOrdrers(Set<WorkOrder> workOrdrers) {
		this.workOrdrers = workOrdrers;
	}
}
